package com.vision.controller;

import com.vision.pojo.AjaxResult;
import com.vision.pojo.vo.PageVO;
import com.vision.pojo.vo.VideoHistoryVO;
import com.vision.service.VideoHistoryService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @projectName: vision
 * @package: com.vision.controller
 * @className: VideoHistoryController
 * @author: escapeicon@gmail.com
 * @description: 视频历史记录控制器
 * @date: 2024/1/28 14:01
 * @version: 1.0
 */
@RestController
@RequestMapping("/videoHistory")
public class VideoHistoryController {
    @Autowired
    private VideoHistoryService videoHistoryService;

    /**
     * 添加视频历史记录
     * @param videoId 视频ID
     * @return AjaxResult
     */
    @PostMapping("/addVideoHistory")
    public AjaxResult addVideoHistory(@NotNull Integer videoId) {
        videoHistoryService.addVideoHistory(videoId);
        return AjaxResult.success();
    }

    /**
     * 获取视频历史记录
     * @param pageNum 页码
     * @param pageSize 页数
     * @return AjaxResult
     */
    @GetMapping("/getVideoHistoryForPage")
    public AjaxResult<PageVO<VideoHistoryVO>> getVideoHistoryForPage(
            @NotNull Integer pageNum,
            @NotNull Integer pageSize
    ) {
        return AjaxResult.success(videoHistoryService.getVideoHistoryForPage(pageNum,pageSize));
    }
}
